{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Exploratury Data Analysis\n",
    "By Minaduki 2019.    \n",
    "项目的Git存储库：https://git.nju.edu.cn/Minaduki/datascience     \n",
    "本作业数据来源自：https://github.com/cmawer/pycon-2017-eda-tutorial       \n",
    "This is a EDA using the Food and Agriculture Organization(FAO) of the United Nation's AQUASTAT dataset.    \n",
    "The data used can be found [here](http://www.fao.org/nr/water/aquastat/data/query/index.html).      "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import seaborn as sns\n",
    "import matplotlib.pyplot as plt\n",
    "from scipy import stats\n",
    "import math\n",
    "import statistics\n",
    "import random"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 数据导入\n",
    "首先，从下载好的gunzip文件中导入数据，pandas支持通过指定压缩方式直接读取压缩文件内的数据表。   \n",
    "读取完毕后先打印出对数据的一些总结，如下所示："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 143280 entries, 0 to 143279\n",
      "Data columns (total 7 columns):\n",
      "country          143280 non-null object\n",
      "region           143280 non-null object\n",
      "variable         143280 non-null object\n",
      "variable_full    143280 non-null object\n",
      "time_period      143280 non-null object\n",
      "year_measured    96411 non-null float64\n",
      "value            96411 non-null float64\n",
      "dtypes: float64(2), object(5)\n",
      "memory usage: 4.9+ MB\n",
      "None\n"
     ]
    }
   ],
   "source": [
    "data = pd.read_csv('aquastat.csv.gzip', compression='gzip')\n",
    "print(data.info())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "可以看见，数据表总共有14万个项目，分为7栏，其中统计年份与统计值为数值。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "打印出数据表的前十行，看一看数据表的样子："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>country</th>\n",
       "      <th>region</th>\n",
       "      <th>variable</th>\n",
       "      <th>variable_full</th>\n",
       "      <th>time_period</th>\n",
       "      <th>year_measured</th>\n",
       "      <th>value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>World | Asia</td>\n",
       "      <td>total_area</td>\n",
       "      <td>Total area of the country (1000 ha)</td>\n",
       "      <td>1958-1962</td>\n",
       "      <td>1962.0</td>\n",
       "      <td>65286.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1</td>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>World | Asia</td>\n",
       "      <td>total_area</td>\n",
       "      <td>Total area of the country (1000 ha)</td>\n",
       "      <td>1963-1967</td>\n",
       "      <td>1967.0</td>\n",
       "      <td>65286.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2</td>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>World | Asia</td>\n",
       "      <td>total_area</td>\n",
       "      <td>Total area of the country (1000 ha)</td>\n",
       "      <td>1968-1972</td>\n",
       "      <td>1972.0</td>\n",
       "      <td>65286.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3</td>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>World | Asia</td>\n",
       "      <td>total_area</td>\n",
       "      <td>Total area of the country (1000 ha)</td>\n",
       "      <td>1973-1977</td>\n",
       "      <td>1977.0</td>\n",
       "      <td>65286.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4</td>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>World | Asia</td>\n",
       "      <td>total_area</td>\n",
       "      <td>Total area of the country (1000 ha)</td>\n",
       "      <td>1978-1982</td>\n",
       "      <td>1982.0</td>\n",
       "      <td>65286.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>5</td>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>World | Asia</td>\n",
       "      <td>total_area</td>\n",
       "      <td>Total area of the country (1000 ha)</td>\n",
       "      <td>1983-1987</td>\n",
       "      <td>1987.0</td>\n",
       "      <td>65286.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>6</td>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>World | Asia</td>\n",
       "      <td>total_area</td>\n",
       "      <td>Total area of the country (1000 ha)</td>\n",
       "      <td>1988-1992</td>\n",
       "      <td>1992.0</td>\n",
       "      <td>65286.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>7</td>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>World | Asia</td>\n",
       "      <td>total_area</td>\n",
       "      <td>Total area of the country (1000 ha)</td>\n",
       "      <td>1993-1997</td>\n",
       "      <td>1997.0</td>\n",
       "      <td>65286.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>8</td>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>World | Asia</td>\n",
       "      <td>total_area</td>\n",
       "      <td>Total area of the country (1000 ha)</td>\n",
       "      <td>1998-2002</td>\n",
       "      <td>2002.0</td>\n",
       "      <td>65286.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>9</td>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>World | Asia</td>\n",
       "      <td>total_area</td>\n",
       "      <td>Total area of the country (1000 ha)</td>\n",
       "      <td>2003-2007</td>\n",
       "      <td>2007.0</td>\n",
       "      <td>65286.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       country        region    variable                        variable_full  \\\n",
       "0  Afghanistan  World | Asia  total_area  Total area of the country (1000 ha)   \n",
       "1  Afghanistan  World | Asia  total_area  Total area of the country (1000 ha)   \n",
       "2  Afghanistan  World | Asia  total_area  Total area of the country (1000 ha)   \n",
       "3  Afghanistan  World | Asia  total_area  Total area of the country (1000 ha)   \n",
       "4  Afghanistan  World | Asia  total_area  Total area of the country (1000 ha)   \n",
       "5  Afghanistan  World | Asia  total_area  Total area of the country (1000 ha)   \n",
       "6  Afghanistan  World | Asia  total_area  Total area of the country (1000 ha)   \n",
       "7  Afghanistan  World | Asia  total_area  Total area of the country (1000 ha)   \n",
       "8  Afghanistan  World | Asia  total_area  Total area of the country (1000 ha)   \n",
       "9  Afghanistan  World | Asia  total_area  Total area of the country (1000 ha)   \n",
       "\n",
       "  time_period  year_measured    value  \n",
       "0   1958-1962         1962.0  65286.0  \n",
       "1   1963-1967         1967.0  65286.0  \n",
       "2   1968-1972         1972.0  65286.0  \n",
       "3   1973-1977         1977.0  65286.0  \n",
       "4   1978-1982         1982.0  65286.0  \n",
       "5   1983-1987         1987.0  65286.0  \n",
       "6   1988-1992         1992.0  65286.0  \n",
       "7   1993-1997         1997.0  65286.0  \n",
       "8   1998-2002         2002.0  65286.0  \n",
       "9   2003-2007         2007.0  65286.0  "
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head(10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 初步特征分析\n",
    "首先，我们可以从数据中总结一些显而易见的内容，比如说数据总共包含了多少国家/地区："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "There are 199 countires/regions in total.\n"
     ]
    }
   ],
   "source": [
    "countries = data.country.unique()\n",
    "# print(countries)\n",
    "print('There are %d countires/regions in total.' %data.country.nunique())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "对于每个国家/地区，总共有多少个统计时间区间："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['1958-1962' '1963-1967' '1968-1972' '1973-1977' '1978-1982' '1983-1987'\n",
      " '1988-1992' '1993-1997' '1998-2002' '2003-2007' '2008-2012' '2013-2017']\n",
      "There are 12 time periods in total.\n"
     ]
    }
   ],
   "source": [
    "time_periods = data.time_period.unique()\n",
    "print(time_periods)\n",
    "print('There are %d time periods in total.' %data.time_period.nunique())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "另外，我们还能从表格中的variable得到总共有哪些方面的统计数据："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>variable</th>\n",
       "      <th>variable_full</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>total_area</td>\n",
       "      <td>Total area of the country (1000 ha)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>576</td>\n",
       "      <td>arable_land</td>\n",
       "      <td>Arable land area (1000 ha)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1152</td>\n",
       "      <td>permanent_crop_area</td>\n",
       "      <td>Permanent crops area (1000 ha)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>1728</td>\n",
       "      <td>cultivated_area</td>\n",
       "      <td>Cultivated area (arable land + permanent crops...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2304</td>\n",
       "      <td>percent_cultivated</td>\n",
       "      <td>% of total country area cultivated (%)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>2880</td>\n",
       "      <td>total_pop</td>\n",
       "      <td>Total population (1000 inhab)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>3456</td>\n",
       "      <td>rural_pop</td>\n",
       "      <td>Rural population (1000 inhab)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4032</td>\n",
       "      <td>urban_pop</td>\n",
       "      <td>Urban population (1000 inhab)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>4608</td>\n",
       "      <td>gdp</td>\n",
       "      <td>Gross Domestic Product (GDP) (current US$)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>5184</td>\n",
       "      <td>gdp_per_capita</td>\n",
       "      <td>GDP per capita (current US$/inhab)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>5760</td>\n",
       "      <td>agg_to_gdp</td>\n",
       "      <td>Agriculture, value added to GDP (%)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>6336</td>\n",
       "      <td>human_dev_index</td>\n",
       "      <td>Human Development Index (HDI) [highest = 1] (-)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>6912</td>\n",
       "      <td>gender_inequal_index</td>\n",
       "      <td>Gender Inequality Index (GII) [equality = 0; i...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>7488</td>\n",
       "      <td>percent_undernourished</td>\n",
       "      <td>Prevalence of undernourishment (3-year average...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>8064</td>\n",
       "      <td>number_undernourished</td>\n",
       "      <td>Number of people undernourished (3-year averag...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>8640</td>\n",
       "      <td>avg_annual_rain_depth</td>\n",
       "      <td>Long-term average annual precipitation in dept...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>9216</td>\n",
       "      <td>avg_annual_rain_vol</td>\n",
       "      <td>Long-term average annual precipitation in volu...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>9792</td>\n",
       "      <td>national_rainfall_index</td>\n",
       "      <td>National Rainfall Index (NRI) (mm/year)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>10368</td>\n",
       "      <td>surface_water_produced</td>\n",
       "      <td>Surface water produced internally (10^9 m3/year)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>10944</td>\n",
       "      <td>groundwater_produced</td>\n",
       "      <td>Groundwater produced internally (10^9 m3/year)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>11520</td>\n",
       "      <td>surface_groundwater_overlap</td>\n",
       "      <td>Overlap between surface water and groundwater ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>12096</td>\n",
       "      <td>irwr</td>\n",
       "      <td>Total internal renewable water resources (IRWR...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>12672</td>\n",
       "      <td>irwr_per_capita</td>\n",
       "      <td>Total internal renewable water resources per c...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>13248</td>\n",
       "      <td>surface_entering</td>\n",
       "      <td>Surface water: entering the country (total) (1...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>13824</td>\n",
       "      <td>surface_inflow_submit_no_treaty</td>\n",
       "      <td>Surface water: inflow not submitted to treatie...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>14400</td>\n",
       "      <td>surface_inflow_submit_treaty</td>\n",
       "      <td>Surface water: inflow submitted to treaties (1...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>14976</td>\n",
       "      <td>surface_inflow_secure_treaty</td>\n",
       "      <td>Surface water: inflow secured through treaties...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>15552</td>\n",
       "      <td>total_flow_border_rivers</td>\n",
       "      <td>Surface water: total flow of border rivers (10...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>16128</td>\n",
       "      <td>accounted_flow_border_rivers</td>\n",
       "      <td>Surface water: accounted flow of border rivers...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>16704</td>\n",
       "      <td>accounted_flow</td>\n",
       "      <td>Surface water: accounted inflow (10^9 m3/year)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>17280</td>\n",
       "      <td>surface_to_other_countries</td>\n",
       "      <td>Surface water: leaving the country to other co...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>17856</td>\n",
       "      <td>surface_outflow_submit_no_treaty</td>\n",
       "      <td>Surface water: outflow to other countries not ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>18432</td>\n",
       "      <td>surface_outflow_submit_treaty</td>\n",
       "      <td>Surface water: outflow to other countries subm...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>19008</td>\n",
       "      <td>surface_outflow_secure_treaty</td>\n",
       "      <td>Surface water: outflow to other countries secu...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>19584</td>\n",
       "      <td>surface_total_external_renewable</td>\n",
       "      <td>Surface water: total external renewable (10^9 ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>20160</td>\n",
       "      <td>groundwater_entering</td>\n",
       "      <td>Groundwater: entering the country (total) (10^...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>20736</td>\n",
       "      <td>groundwater_accounted_inflow</td>\n",
       "      <td>Groundwater: accounted inflow (10^9 m3/year)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>21312</td>\n",
       "      <td>groundwater_to_other_countries</td>\n",
       "      <td>Groundwater: leaving the country to other coun...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>21888</td>\n",
       "      <td>groundwater_accounted_outflow</td>\n",
       "      <td>Groundwater: accounted outflow to other countr...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>22464</td>\n",
       "      <td>water_total_external_renewable</td>\n",
       "      <td>Water resources: total external renewable (10^...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>23040</td>\n",
       "      <td>total_renewable_surface</td>\n",
       "      <td>Total renewable surface water (10^9 m3/year)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>23616</td>\n",
       "      <td>total_renewable_groundwater</td>\n",
       "      <td>Total renewable groundwater (10^9 m3/year)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>24192</td>\n",
       "      <td>overlap_surface_groundwater</td>\n",
       "      <td>Overlap: between surface water and groundwater...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>24768</td>\n",
       "      <td>total_renewable</td>\n",
       "      <td>Total renewable water resources (10^9 m3/year)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>25344</td>\n",
       "      <td>dependency_ratio</td>\n",
       "      <td>Dependency ratio (%)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>25920</td>\n",
       "      <td>total_renewable_per_capita</td>\n",
       "      <td>Total renewable water resources per capita (m3...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>26496</td>\n",
       "      <td>exploitable_regular_renewable_surface</td>\n",
       "      <td>Exploitable: regular renewable surface water (...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>27072</td>\n",
       "      <td>exploitable_irregular_renewable_surface</td>\n",
       "      <td>Exploitable: irregular renewable surface water...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>27648</td>\n",
       "      <td>exploitable_total_renewable_surface</td>\n",
       "      <td>Exploitable: total renewable surface water (10...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>28224</td>\n",
       "      <td>exploitable_regular_renewable_groundwater</td>\n",
       "      <td>Exploitable: regular renewable groundwater (10...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>28800</td>\n",
       "      <td>exploitable_total</td>\n",
       "      <td>Total exploitable water resources (10^9 m3/year)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>29376</td>\n",
       "      <td>interannual_variability</td>\n",
       "      <td>Interannual variability (WRI) (-)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>29952</td>\n",
       "      <td>seasonal_variability</td>\n",
       "      <td>Seasonal variability (WRI) (-)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>30528</td>\n",
       "      <td>total_dam_capacity</td>\n",
       "      <td>Total dam capacity (km3)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>31104</td>\n",
       "      <td>dam_capacity_per_capita</td>\n",
       "      <td>Dam capacity per capita (m3/inhab)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>31680</td>\n",
       "      <td>irrigation_potential</td>\n",
       "      <td>Irrigation potential (1000 ha)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>32256</td>\n",
       "      <td>flood_occurence</td>\n",
       "      <td>Flood occurrence (WRI) (-)</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>32832</td>\n",
       "      <td>total_pop_access_drinking</td>\n",
       "      <td>Total population with access to safe drinking-...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>33408</td>\n",
       "      <td>rural_pop_access_drinking</td>\n",
       "      <td>Rural population with access to safe drinking-...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>33984</td>\n",
       "      <td>urban_pop_access_drinking</td>\n",
       "      <td>Urban population with access to safe drinking-...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                        variable  \\\n",
       "0                                     total_area   \n",
       "576                                  arable_land   \n",
       "1152                         permanent_crop_area   \n",
       "1728                             cultivated_area   \n",
       "2304                          percent_cultivated   \n",
       "2880                                   total_pop   \n",
       "3456                                   rural_pop   \n",
       "4032                                   urban_pop   \n",
       "4608                                         gdp   \n",
       "5184                              gdp_per_capita   \n",
       "5760                                  agg_to_gdp   \n",
       "6336                             human_dev_index   \n",
       "6912                        gender_inequal_index   \n",
       "7488                      percent_undernourished   \n",
       "8064                       number_undernourished   \n",
       "8640                       avg_annual_rain_depth   \n",
       "9216                         avg_annual_rain_vol   \n",
       "9792                     national_rainfall_index   \n",
       "10368                     surface_water_produced   \n",
       "10944                       groundwater_produced   \n",
       "11520                surface_groundwater_overlap   \n",
       "12096                                       irwr   \n",
       "12672                            irwr_per_capita   \n",
       "13248                           surface_entering   \n",
       "13824            surface_inflow_submit_no_treaty   \n",
       "14400               surface_inflow_submit_treaty   \n",
       "14976               surface_inflow_secure_treaty   \n",
       "15552                   total_flow_border_rivers   \n",
       "16128               accounted_flow_border_rivers   \n",
       "16704                             accounted_flow   \n",
       "17280                 surface_to_other_countries   \n",
       "17856           surface_outflow_submit_no_treaty   \n",
       "18432              surface_outflow_submit_treaty   \n",
       "19008              surface_outflow_secure_treaty   \n",
       "19584           surface_total_external_renewable   \n",
       "20160                       groundwater_entering   \n",
       "20736               groundwater_accounted_inflow   \n",
       "21312             groundwater_to_other_countries   \n",
       "21888              groundwater_accounted_outflow   \n",
       "22464             water_total_external_renewable   \n",
       "23040                    total_renewable_surface   \n",
       "23616                total_renewable_groundwater   \n",
       "24192                overlap_surface_groundwater   \n",
       "24768                            total_renewable   \n",
       "25344                           dependency_ratio   \n",
       "25920                 total_renewable_per_capita   \n",
       "26496      exploitable_regular_renewable_surface   \n",
       "27072    exploitable_irregular_renewable_surface   \n",
       "27648        exploitable_total_renewable_surface   \n",
       "28224  exploitable_regular_renewable_groundwater   \n",
       "28800                          exploitable_total   \n",
       "29376                    interannual_variability   \n",
       "29952                       seasonal_variability   \n",
       "30528                         total_dam_capacity   \n",
       "31104                    dam_capacity_per_capita   \n",
       "31680                       irrigation_potential   \n",
       "32256                            flood_occurence   \n",
       "32832                  total_pop_access_drinking   \n",
       "33408                  rural_pop_access_drinking   \n",
       "33984                  urban_pop_access_drinking   \n",
       "\n",
       "                                           variable_full  \n",
       "0                    Total area of the country (1000 ha)  \n",
       "576                           Arable land area (1000 ha)  \n",
       "1152                      Permanent crops area (1000 ha)  \n",
       "1728   Cultivated area (arable land + permanent crops...  \n",
       "2304              % of total country area cultivated (%)  \n",
       "2880                       Total population (1000 inhab)  \n",
       "3456                       Rural population (1000 inhab)  \n",
       "4032                       Urban population (1000 inhab)  \n",
       "4608          Gross Domestic Product (GDP) (current US$)  \n",
       "5184                  GDP per capita (current US$/inhab)  \n",
       "5760                 Agriculture, value added to GDP (%)  \n",
       "6336     Human Development Index (HDI) [highest = 1] (-)  \n",
       "6912   Gender Inequality Index (GII) [equality = 0; i...  \n",
       "7488   Prevalence of undernourishment (3-year average...  \n",
       "8064   Number of people undernourished (3-year averag...  \n",
       "8640   Long-term average annual precipitation in dept...  \n",
       "9216   Long-term average annual precipitation in volu...  \n",
       "9792             National Rainfall Index (NRI) (mm/year)  \n",
       "10368   Surface water produced internally (10^9 m3/year)  \n",
       "10944     Groundwater produced internally (10^9 m3/year)  \n",
       "11520  Overlap between surface water and groundwater ...  \n",
       "12096  Total internal renewable water resources (IRWR...  \n",
       "12672  Total internal renewable water resources per c...  \n",
       "13248  Surface water: entering the country (total) (1...  \n",
       "13824  Surface water: inflow not submitted to treatie...  \n",
       "14400  Surface water: inflow submitted to treaties (1...  \n",
       "14976  Surface water: inflow secured through treaties...  \n",
       "15552  Surface water: total flow of border rivers (10...  \n",
       "16128  Surface water: accounted flow of border rivers...  \n",
       "16704     Surface water: accounted inflow (10^9 m3/year)  \n",
       "17280  Surface water: leaving the country to other co...  \n",
       "17856  Surface water: outflow to other countries not ...  \n",
       "18432  Surface water: outflow to other countries subm...  \n",
       "19008  Surface water: outflow to other countries secu...  \n",
       "19584  Surface water: total external renewable (10^9 ...  \n",
       "20160  Groundwater: entering the country (total) (10^...  \n",
       "20736       Groundwater: accounted inflow (10^9 m3/year)  \n",
       "21312  Groundwater: leaving the country to other coun...  \n",
       "21888  Groundwater: accounted outflow to other countr...  \n",
       "22464  Water resources: total external renewable (10^...  \n",
       "23040       Total renewable surface water (10^9 m3/year)  \n",
       "23616         Total renewable groundwater (10^9 m3/year)  \n",
       "24192  Overlap: between surface water and groundwater...  \n",
       "24768     Total renewable water resources (10^9 m3/year)  \n",
       "25344                               Dependency ratio (%)  \n",
       "25920  Total renewable water resources per capita (m3...  \n",
       "26496  Exploitable: regular renewable surface water (...  \n",
       "27072  Exploitable: irregular renewable surface water...  \n",
       "27648  Exploitable: total renewable surface water (10...  \n",
       "28224  Exploitable: regular renewable groundwater (10...  \n",
       "28800   Total exploitable water resources (10^9 m3/year)  \n",
       "29376                  Interannual variability (WRI) (-)  \n",
       "29952                     Seasonal variability (WRI) (-)  \n",
       "30528                           Total dam capacity (km3)  \n",
       "31104                 Dam capacity per capita (m3/inhab)  \n",
       "31680                     Irrigation potential (1000 ha)  \n",
       "32256                         Flood occurrence (WRI) (-)  \n",
       "32832  Total population with access to safe drinking-...  \n",
       "33408  Rural population with access to safe drinking-...  \n",
       "33984  Urban population with access to safe drinking-...  "
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data[['variable','variable_full']].drop_duplicates()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 数据缺失值与处理\n",
    "缺失值会影响到后续的分析，需要对其缺失值进去处理，丢弃或者替代。   \n",
    "首先，查看总共有几处数据值是空缺的："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "46869"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.value.isnull().sum()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "有46869处缺失，为了方便起见都删掉吧，反正数据总量不小，使用dropna命令删掉对应的项目"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 96411 entries, 0 to 143279\n",
      "Data columns (total 7 columns):\n",
      "country          96411 non-null object\n",
      "region           96411 non-null object\n",
      "variable         96411 non-null object\n",
      "variable_full    96411 non-null object\n",
      "time_period      96411 non-null object\n",
      "year_measured    96411 non-null float64\n",
      "value            96411 non-null float64\n",
      "dtypes: float64(2), object(5)\n",
      "memory usage: 4.0+ MB\n"
     ]
    }
   ],
   "source": [
    "my_data = data.dropna(axis=0)\n",
    "my_data.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "可以看出，现在的数据表格就没有空项目了。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 冗余判断\n",
    "数据冗余分为行冗余及列冗余，行冗余表现为重复样本，列冗余表现为一些特征之间具有简单的线性关系。    \n",
    "首先看看是否存在行冗余："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0         False\n",
       "1         False\n",
       "2         False\n",
       "3         False\n",
       "4         False\n",
       "          ...  \n",
       "143275    False\n",
       "143276    False\n",
       "143277    False\n",
       "143278    False\n",
       "143279    False\n",
       "Length: 96411, dtype: bool"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "my_data.duplicated()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "看来没有。    \n",
    "列冗余由于就一列数据，也肯定没有。    \n",
    "如果强行要说的话，variable字段和variable_full字段相当与简称和全程，可以省略一个，但是意义不大，这里就不删去了。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 数据划分\n",
    "可以看出，所给的数据其实来源于多个统计项目，因此要把不同的统计项目切分出来，方便数据处理。    \n",
    "这里使用一个自定义的函数完成对不同统计项目的slicing，实现如下："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [],
   "source": [
    "def slice_by_variable(dataframe, variable):\n",
    "    dataframe = dataframe[dataframe.variable==variable]\n",
    "    dataframe = dataframe.pivot(index='country', columns='time_period', values='value')\n",
    "    return dataframe"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "把gdp统计切出来看看（顺便一提，为了保持表格美观，所有有缺失的国家都被drop了）："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>time_period</th>\n",
       "      <th>1958-1962</th>\n",
       "      <th>1963-1967</th>\n",
       "      <th>1968-1972</th>\n",
       "      <th>1973-1977</th>\n",
       "      <th>1978-1982</th>\n",
       "      <th>1983-1987</th>\n",
       "      <th>1988-1992</th>\n",
       "      <th>1993-1997</th>\n",
       "      <th>1998-2002</th>\n",
       "      <th>2003-2007</th>\n",
       "      <th>2008-2012</th>\n",
       "      <th>2013-2017</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>country</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>Algeria</td>\n",
       "      <td>2.001461e+09</td>\n",
       "      <td>3.370870e+09</td>\n",
       "      <td>6.761786e+09</td>\n",
       "      <td>2.097190e+10</td>\n",
       "      <td>4.520709e+10</td>\n",
       "      <td>6.674227e+10</td>\n",
       "      <td>4.800330e+10</td>\n",
       "      <td>4.817786e+10</td>\n",
       "      <td>5.676029e+10</td>\n",
       "      <td>1.350000e+11</td>\n",
       "      <td>2.090000e+11</td>\n",
       "      <td>1.670000e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>Argentina</td>\n",
       "      <td>2.445060e+10</td>\n",
       "      <td>2.425667e+10</td>\n",
       "      <td>3.473300e+10</td>\n",
       "      <td>5.678100e+10</td>\n",
       "      <td>8.430749e+10</td>\n",
       "      <td>1.110000e+11</td>\n",
       "      <td>2.290000e+11</td>\n",
       "      <td>2.930000e+11</td>\n",
       "      <td>9.772451e+10</td>\n",
       "      <td>3.290000e+11</td>\n",
       "      <td>6.040000e+11</td>\n",
       "      <td>5.480000e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>Australia</td>\n",
       "      <td>1.988353e+10</td>\n",
       "      <td>3.037854e+10</td>\n",
       "      <td>5.192874e+10</td>\n",
       "      <td>1.100000e+11</td>\n",
       "      <td>1.940000e+11</td>\n",
       "      <td>1.890000e+11</td>\n",
       "      <td>3.250000e+11</td>\n",
       "      <td>4.360000e+11</td>\n",
       "      <td>3.940000e+11</td>\n",
       "      <td>8.530000e+11</td>\n",
       "      <td>1.540000e+12</td>\n",
       "      <td>1.340000e+12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>Austria</td>\n",
       "      <td>7.756110e+09</td>\n",
       "      <td>1.157943e+10</td>\n",
       "      <td>2.200647e+10</td>\n",
       "      <td>5.142159e+10</td>\n",
       "      <td>7.110359e+10</td>\n",
       "      <td>1.240000e+11</td>\n",
       "      <td>1.950000e+11</td>\n",
       "      <td>2.120000e+11</td>\n",
       "      <td>2.130000e+11</td>\n",
       "      <td>3.860000e+11</td>\n",
       "      <td>4.070000e+11</td>\n",
       "      <td>3.740000e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>Bahamas</td>\n",
       "      <td>2.122528e+08</td>\n",
       "      <td>3.901961e+08</td>\n",
       "      <td>5.909000e+08</td>\n",
       "      <td>7.130000e+08</td>\n",
       "      <td>1.578300e+09</td>\n",
       "      <td>2.714000e+09</td>\n",
       "      <td>3.109000e+09</td>\n",
       "      <td>4.961119e+09</td>\n",
       "      <td>6.957996e+09</td>\n",
       "      <td>8.318996e+09</td>\n",
       "      <td>8.234470e+09</td>\n",
       "      <td>8.884441e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>Bangladesh</td>\n",
       "      <td>5.081413e+09</td>\n",
       "      <td>7.253575e+09</td>\n",
       "      <td>6.288246e+09</td>\n",
       "      <td>9.651149e+09</td>\n",
       "      <td>1.852540e+10</td>\n",
       "      <td>2.429803e+10</td>\n",
       "      <td>3.170887e+10</td>\n",
       "      <td>4.824431e+10</td>\n",
       "      <td>5.472408e+10</td>\n",
       "      <td>7.961189e+10</td>\n",
       "      <td>1.330000e+11</td>\n",
       "      <td>1.950000e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>Barbados</td>\n",
       "      <td>9.694976e+07</td>\n",
       "      <td>1.371037e+08</td>\n",
       "      <td>2.333836e+08</td>\n",
       "      <td>4.951166e+08</td>\n",
       "      <td>1.163924e+09</td>\n",
       "      <td>1.704370e+09</td>\n",
       "      <td>1.957000e+09</td>\n",
       "      <td>2.549097e+09</td>\n",
       "      <td>3.169500e+09</td>\n",
       "      <td>4.546000e+09</td>\n",
       "      <td>4.313000e+09</td>\n",
       "      <td>4.451000e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>Belgium</td>\n",
       "      <td>1.326402e+10</td>\n",
       "      <td>1.999204e+10</td>\n",
       "      <td>3.740863e+10</td>\n",
       "      <td>8.328341e+10</td>\n",
       "      <td>9.258898e+10</td>\n",
       "      <td>1.500000e+11</td>\n",
       "      <td>2.360000e+11</td>\n",
       "      <td>2.550000e+11</td>\n",
       "      <td>2.590000e+11</td>\n",
       "      <td>4.720000e+11</td>\n",
       "      <td>4.980000e+11</td>\n",
       "      <td>4.540000e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>Belize</td>\n",
       "      <td>3.185759e+07</td>\n",
       "      <td>4.737931e+07</td>\n",
       "      <td>6.606250e+07</td>\n",
       "      <td>1.176500e+08</td>\n",
       "      <td>1.792500e+08</td>\n",
       "      <td>2.765500e+08</td>\n",
       "      <td>5.182391e+08</td>\n",
       "      <td>6.543144e+08</td>\n",
       "      <td>9.325518e+08</td>\n",
       "      <td>1.290543e+09</td>\n",
       "      <td>1.573619e+09</td>\n",
       "      <td>1.763000e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>Benin</td>\n",
       "      <td>2.364350e+08</td>\n",
       "      <td>3.062220e+08</td>\n",
       "      <td>4.103319e+08</td>\n",
       "      <td>7.500498e+08</td>\n",
       "      <td>1.267779e+09</td>\n",
       "      <td>1.562412e+09</td>\n",
       "      <td>1.695315e+09</td>\n",
       "      <td>2.268302e+09</td>\n",
       "      <td>3.054571e+09</td>\n",
       "      <td>5.969535e+09</td>\n",
       "      <td>8.117101e+09</td>\n",
       "      <td>8.476125e+09</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "time_period     1958-1962     1963-1967     1968-1972     1973-1977  \\\n",
       "country                                                               \n",
       "Algeria      2.001461e+09  3.370870e+09  6.761786e+09  2.097190e+10   \n",
       "Argentina    2.445060e+10  2.425667e+10  3.473300e+10  5.678100e+10   \n",
       "Australia    1.988353e+10  3.037854e+10  5.192874e+10  1.100000e+11   \n",
       "Austria      7.756110e+09  1.157943e+10  2.200647e+10  5.142159e+10   \n",
       "Bahamas      2.122528e+08  3.901961e+08  5.909000e+08  7.130000e+08   \n",
       "Bangladesh   5.081413e+09  7.253575e+09  6.288246e+09  9.651149e+09   \n",
       "Barbados     9.694976e+07  1.371037e+08  2.333836e+08  4.951166e+08   \n",
       "Belgium      1.326402e+10  1.999204e+10  3.740863e+10  8.328341e+10   \n",
       "Belize       3.185759e+07  4.737931e+07  6.606250e+07  1.176500e+08   \n",
       "Benin        2.364350e+08  3.062220e+08  4.103319e+08  7.500498e+08   \n",
       "\n",
       "time_period     1978-1982     1983-1987     1988-1992     1993-1997  \\\n",
       "country                                                               \n",
       "Algeria      4.520709e+10  6.674227e+10  4.800330e+10  4.817786e+10   \n",
       "Argentina    8.430749e+10  1.110000e+11  2.290000e+11  2.930000e+11   \n",
       "Australia    1.940000e+11  1.890000e+11  3.250000e+11  4.360000e+11   \n",
       "Austria      7.110359e+10  1.240000e+11  1.950000e+11  2.120000e+11   \n",
       "Bahamas      1.578300e+09  2.714000e+09  3.109000e+09  4.961119e+09   \n",
       "Bangladesh   1.852540e+10  2.429803e+10  3.170887e+10  4.824431e+10   \n",
       "Barbados     1.163924e+09  1.704370e+09  1.957000e+09  2.549097e+09   \n",
       "Belgium      9.258898e+10  1.500000e+11  2.360000e+11  2.550000e+11   \n",
       "Belize       1.792500e+08  2.765500e+08  5.182391e+08  6.543144e+08   \n",
       "Benin        1.267779e+09  1.562412e+09  1.695315e+09  2.268302e+09   \n",
       "\n",
       "time_period     1998-2002     2003-2007     2008-2012     2013-2017  \n",
       "country                                                              \n",
       "Algeria      5.676029e+10  1.350000e+11  2.090000e+11  1.670000e+11  \n",
       "Argentina    9.772451e+10  3.290000e+11  6.040000e+11  5.480000e+11  \n",
       "Australia    3.940000e+11  8.530000e+11  1.540000e+12  1.340000e+12  \n",
       "Austria      2.130000e+11  3.860000e+11  4.070000e+11  3.740000e+11  \n",
       "Bahamas      6.957996e+09  8.318996e+09  8.234470e+09  8.884441e+09  \n",
       "Bangladesh   5.472408e+10  7.961189e+10  1.330000e+11  1.950000e+11  \n",
       "Barbados     3.169500e+09  4.546000e+09  4.313000e+09  4.451000e+09  \n",
       "Belgium      2.590000e+11  4.720000e+11  4.980000e+11  4.540000e+11  \n",
       "Belize       9.325518e+08  1.290543e+09  1.573619e+09  1.763000e+09  \n",
       "Benin        3.054571e+09  5.969535e+09  8.117101e+09  8.476125e+09  "
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "slice_by_variable(my_data, 'gdp').dropna(axis=0).head(10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "当然，也可以对一个国家的多个项目进行比较："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [],
   "source": [
    "def slice_by_country(dataframe, country):\n",
    "    dataframe = dataframe[dataframe.country==country] \n",
    "    dataframe = dataframe.pivot(index='variable', columns='time_period', values='value')\n",
    "    dataframe.index.name = country\n",
    "    return dataframe"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "随机抽取一个幸运国家进行展示如下："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>time_period</th>\n",
       "      <th>1958-1962</th>\n",
       "      <th>1963-1967</th>\n",
       "      <th>1968-1972</th>\n",
       "      <th>1973-1977</th>\n",
       "      <th>1978-1982</th>\n",
       "      <th>1983-1987</th>\n",
       "      <th>1988-1992</th>\n",
       "      <th>1993-1997</th>\n",
       "      <th>1998-2002</th>\n",
       "      <th>2003-2007</th>\n",
       "      <th>2008-2012</th>\n",
       "      <th>2013-2017</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Chad</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>accounted_flow</td>\n",
       "      <td>30.70</td>\n",
       "      <td>30.70</td>\n",
       "      <td>30.70</td>\n",
       "      <td>30.70</td>\n",
       "      <td>30.70</td>\n",
       "      <td>30.70</td>\n",
       "      <td>30.70</td>\n",
       "      <td>30.70</td>\n",
       "      <td>30.70</td>\n",
       "      <td>30.70</td>\n",
       "      <td>30.70</td>\n",
       "      <td>30.70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>accounted_flow_border_rivers</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>agg_to_gdp</td>\n",
       "      <td>39.81</td>\n",
       "      <td>42.08</td>\n",
       "      <td>39.52</td>\n",
       "      <td>35.17</td>\n",
       "      <td>39.46</td>\n",
       "      <td>33.11</td>\n",
       "      <td>35.34</td>\n",
       "      <td>39.94</td>\n",
       "      <td>39.44</td>\n",
       "      <td>56.00</td>\n",
       "      <td>55.09</td>\n",
       "      <td>52.39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>arable_land</td>\n",
       "      <td>2897.00</td>\n",
       "      <td>2897.00</td>\n",
       "      <td>2897.00</td>\n",
       "      <td>3095.00</td>\n",
       "      <td>3132.00</td>\n",
       "      <td>3180.00</td>\n",
       "      <td>3342.00</td>\n",
       "      <td>3600.00</td>\n",
       "      <td>3700.00</td>\n",
       "      <td>4300.00</td>\n",
       "      <td>4900.00</td>\n",
       "      <td>4900.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>avg_annual_rain_depth</td>\n",
       "      <td>322.00</td>\n",
       "      <td>322.00</td>\n",
       "      <td>322.00</td>\n",
       "      <td>322.00</td>\n",
       "      <td>322.00</td>\n",
       "      <td>322.00</td>\n",
       "      <td>322.00</td>\n",
       "      <td>322.00</td>\n",
       "      <td>322.00</td>\n",
       "      <td>322.00</td>\n",
       "      <td>322.00</td>\n",
       "      <td>322.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>avg_annual_rain_vol</td>\n",
       "      <td>413.40</td>\n",
       "      <td>413.40</td>\n",
       "      <td>413.40</td>\n",
       "      <td>413.40</td>\n",
       "      <td>413.40</td>\n",
       "      <td>413.40</td>\n",
       "      <td>413.40</td>\n",
       "      <td>413.40</td>\n",
       "      <td>413.40</td>\n",
       "      <td>413.40</td>\n",
       "      <td>413.40</td>\n",
       "      <td>413.40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>cultivated_area</td>\n",
       "      <td>2900.00</td>\n",
       "      <td>2900.00</td>\n",
       "      <td>2900.00</td>\n",
       "      <td>3100.00</td>\n",
       "      <td>3150.00</td>\n",
       "      <td>3205.00</td>\n",
       "      <td>3370.00</td>\n",
       "      <td>3630.00</td>\n",
       "      <td>3730.00</td>\n",
       "      <td>4331.00</td>\n",
       "      <td>4935.00</td>\n",
       "      <td>4935.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>dam_capacity_per_capita</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>dependency_ratio</td>\n",
       "      <td>67.18</td>\n",
       "      <td>67.18</td>\n",
       "      <td>67.18</td>\n",
       "      <td>67.18</td>\n",
       "      <td>67.18</td>\n",
       "      <td>67.18</td>\n",
       "      <td>67.18</td>\n",
       "      <td>67.18</td>\n",
       "      <td>67.18</td>\n",
       "      <td>67.18</td>\n",
       "      <td>67.18</td>\n",
       "      <td>67.18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>exploitable_irregular_renewable_surface</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "time_period                              1958-1962  1963-1967  1968-1972  \\\n",
       "Chad                                                                       \n",
       "accounted_flow                               30.70      30.70      30.70   \n",
       "accounted_flow_border_rivers                  0.00       0.00       0.00   \n",
       "agg_to_gdp                                   39.81      42.08      39.52   \n",
       "arable_land                                2897.00    2897.00    2897.00   \n",
       "avg_annual_rain_depth                       322.00     322.00     322.00   \n",
       "avg_annual_rain_vol                         413.40     413.40     413.40   \n",
       "cultivated_area                            2900.00    2900.00    2900.00   \n",
       "dam_capacity_per_capita                        NaN        NaN        NaN   \n",
       "dependency_ratio                             67.18      67.18      67.18   \n",
       "exploitable_irregular_renewable_surface        NaN        NaN        NaN   \n",
       "\n",
       "time_period                              1973-1977  1978-1982  1983-1987  \\\n",
       "Chad                                                                       \n",
       "accounted_flow                               30.70      30.70      30.70   \n",
       "accounted_flow_border_rivers                  0.00       0.00       0.00   \n",
       "agg_to_gdp                                   35.17      39.46      33.11   \n",
       "arable_land                                3095.00    3132.00    3180.00   \n",
       "avg_annual_rain_depth                       322.00     322.00     322.00   \n",
       "avg_annual_rain_vol                         413.40     413.40     413.40   \n",
       "cultivated_area                            3100.00    3150.00    3205.00   \n",
       "dam_capacity_per_capita                        NaN        NaN        NaN   \n",
       "dependency_ratio                             67.18      67.18      67.18   \n",
       "exploitable_irregular_renewable_surface        NaN        NaN        NaN   \n",
       "\n",
       "time_period                              1988-1992  1993-1997  1998-2002  \\\n",
       "Chad                                                                       \n",
       "accounted_flow                               30.70      30.70      30.70   \n",
       "accounted_flow_border_rivers                  0.00       0.00       0.00   \n",
       "agg_to_gdp                                   35.34      39.94      39.44   \n",
       "arable_land                                3342.00    3600.00    3700.00   \n",
       "avg_annual_rain_depth                       322.00     322.00     322.00   \n",
       "avg_annual_rain_vol                         413.40     413.40     413.40   \n",
       "cultivated_area                            3370.00    3630.00    3730.00   \n",
       "dam_capacity_per_capita                        NaN        NaN        NaN   \n",
       "dependency_ratio                             67.18      67.18      67.18   \n",
       "exploitable_irregular_renewable_surface        NaN        NaN        NaN   \n",
       "\n",
       "time_period                              2003-2007  2008-2012  2013-2017  \n",
       "Chad                                                                      \n",
       "accounted_flow                               30.70      30.70      30.70  \n",
       "accounted_flow_border_rivers                  0.00       0.00       0.00  \n",
       "agg_to_gdp                                   56.00      55.09      52.39  \n",
       "arable_land                                4300.00    4900.00    4900.00  \n",
       "avg_annual_rain_depth                       322.00     322.00     322.00  \n",
       "avg_annual_rain_vol                         413.40     413.40     413.40  \n",
       "cultivated_area                            4331.00    4935.00    4935.00  \n",
       "dam_capacity_per_capita                        NaN        NaN        NaN  \n",
       "dependency_ratio                             67.18      67.18      67.18  \n",
       "exploitable_irregular_renewable_surface        NaN        NaN        NaN  "
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "slice_by_country(data, countries[random.randint(0,100)]).head(10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "或者对一个特定的时间进行横向比较："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [],
   "source": [
    "def slice_by_time(dataframe, time_period):\n",
    "    dataframe = dataframe[dataframe.time_period==time_period] \n",
    "    dataframe = dataframe.pivot(index='country', columns='variable', values='value')\n",
    "    dataframe.columns.name = time_period\n",
    "    return dataframe"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "随机选取一个时间段，进行查看："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>1978-1982</th>\n",
       "      <th>accounted_flow</th>\n",
       "      <th>accounted_flow_border_rivers</th>\n",
       "      <th>agg_to_gdp</th>\n",
       "      <th>arable_land</th>\n",
       "      <th>avg_annual_rain_depth</th>\n",
       "      <th>avg_annual_rain_vol</th>\n",
       "      <th>cultivated_area</th>\n",
       "      <th>dam_capacity_per_capita</th>\n",
       "      <th>dependency_ratio</th>\n",
       "      <th>exploitable_irregular_renewable_surface</th>\n",
       "      <th>...</th>\n",
       "      <th>total_flow_border_rivers</th>\n",
       "      <th>total_pop</th>\n",
       "      <th>total_pop_access_drinking</th>\n",
       "      <th>total_renewable</th>\n",
       "      <th>total_renewable_groundwater</th>\n",
       "      <th>total_renewable_per_capita</th>\n",
       "      <th>total_renewable_surface</th>\n",
       "      <th>urban_pop</th>\n",
       "      <th>urban_pop_access_drinking</th>\n",
       "      <th>water_total_external_renewable</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>country</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>Afghanistan</td>\n",
       "      <td>19.00</td>\n",
       "      <td>9.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>7910.0</td>\n",
       "      <td>327.0</td>\n",
       "      <td>213.5000</td>\n",
       "      <td>8054.0</td>\n",
       "      <td>158.6</td>\n",
       "      <td>28.7200</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>33.4</td>\n",
       "      <td>12667.00</td>\n",
       "      <td>NaN</td>\n",
       "      <td>65.3300</td>\n",
       "      <td>10.650</td>\n",
       "      <td>5157.0</td>\n",
       "      <td>55.68</td>\n",
       "      <td>2045.00</td>\n",
       "      <td>NaN</td>\n",
       "      <td>18.18</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>Albania</td>\n",
       "      <td>3.30</td>\n",
       "      <td>0.0</td>\n",
       "      <td>31.70</td>\n",
       "      <td>589.0</td>\n",
       "      <td>1485.0</td>\n",
       "      <td>42.6900</td>\n",
       "      <td>709.0</td>\n",
       "      <td>1284.0</td>\n",
       "      <td>10.9300</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2788.00</td>\n",
       "      <td>NaN</td>\n",
       "      <td>30.2000</td>\n",
       "      <td>6.200</td>\n",
       "      <td>10832.0</td>\n",
       "      <td>26.35</td>\n",
       "      <td>982.00</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>Algeria</td>\n",
       "      <td>0.39</td>\n",
       "      <td>0.0</td>\n",
       "      <td>8.39</td>\n",
       "      <td>6881.0</td>\n",
       "      <td>89.0</td>\n",
       "      <td>212.0000</td>\n",
       "      <td>7509.0</td>\n",
       "      <td>100.7</td>\n",
       "      <td>3.5990</td>\n",
       "      <td>5.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>20576.00</td>\n",
       "      <td>NaN</td>\n",
       "      <td>11.6700</td>\n",
       "      <td>1.517</td>\n",
       "      <td>567.2</td>\n",
       "      <td>10.15</td>\n",
       "      <td>9408.00</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>Andorra</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.4724</td>\n",
       "      <td>1.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>39.11</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.3156</td>\n",
       "      <td>NaN</td>\n",
       "      <td>8070.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>36.56</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>Angola</td>\n",
       "      <td>0.40</td>\n",
       "      <td>0.0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2900.0</td>\n",
       "      <td>1010.0</td>\n",
       "      <td>1259.0000</td>\n",
       "      <td>3400.0</td>\n",
       "      <td>490.7</td>\n",
       "      <td>0.2695</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>8808.00</td>\n",
       "      <td>NaN</td>\n",
       "      <td>148.4000</td>\n",
       "      <td>58.000</td>\n",
       "      <td>16848.0</td>\n",
       "      <td>145.40</td>\n",
       "      <td>1707.00</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0.40</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 60 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "1978-1982    accounted_flow  accounted_flow_border_rivers  agg_to_gdp  \\\n",
       "country                                                                 \n",
       "Afghanistan           19.00                           9.0         NaN   \n",
       "Albania                3.30                           0.0       31.70   \n",
       "Algeria                0.39                           0.0        8.39   \n",
       "Andorra                 NaN                           NaN         NaN   \n",
       "Angola                 0.40                           0.0         NaN   \n",
       "\n",
       "1978-1982    arable_land  avg_annual_rain_depth  avg_annual_rain_vol  \\\n",
       "country                                                                \n",
       "Afghanistan       7910.0                  327.0             213.5000   \n",
       "Albania            589.0                 1485.0              42.6900   \n",
       "Algeria           6881.0                   89.0             212.0000   \n",
       "Andorra              1.0                    NaN               0.4724   \n",
       "Angola            2900.0                 1010.0            1259.0000   \n",
       "\n",
       "1978-1982    cultivated_area  dam_capacity_per_capita  dependency_ratio  \\\n",
       "country                                                                   \n",
       "Afghanistan           8054.0                    158.6           28.7200   \n",
       "Albania                709.0                   1284.0           10.9300   \n",
       "Algeria               7509.0                    100.7            3.5990   \n",
       "Andorra                  1.0                      NaN               NaN   \n",
       "Angola                3400.0                    490.7            0.2695   \n",
       "\n",
       "1978-1982    exploitable_irregular_renewable_surface  ...  \\\n",
       "country                                               ...   \n",
       "Afghanistan                                      NaN  ...   \n",
       "Albania                                          NaN  ...   \n",
       "Algeria                                          5.0  ...   \n",
       "Andorra                                          NaN  ...   \n",
       "Angola                                           NaN  ...   \n",
       "\n",
       "1978-1982    total_flow_border_rivers  total_pop  total_pop_access_drinking  \\\n",
       "country                                                                       \n",
       "Afghanistan                      33.4   12667.00                        NaN   \n",
       "Albania                           0.0    2788.00                        NaN   \n",
       "Algeria                           0.0   20576.00                        NaN   \n",
       "Andorra                           NaN      39.11                        NaN   \n",
       "Angola                            0.0    8808.00                        NaN   \n",
       "\n",
       "1978-1982    total_renewable  total_renewable_groundwater  \\\n",
       "country                                                     \n",
       "Afghanistan          65.3300                       10.650   \n",
       "Albania              30.2000                        6.200   \n",
       "Algeria              11.6700                        1.517   \n",
       "Andorra               0.3156                          NaN   \n",
       "Angola              148.4000                       58.000   \n",
       "\n",
       "1978-1982    total_renewable_per_capita  total_renewable_surface  urban_pop  \\\n",
       "country                                                                       \n",
       "Afghanistan                      5157.0                    55.68    2045.00   \n",
       "Albania                         10832.0                    26.35     982.00   \n",
       "Algeria                           567.2                    10.15    9408.00   \n",
       "Andorra                          8070.0                      NaN      36.56   \n",
       "Angola                          16848.0                   145.40    1707.00   \n",
       "\n",
       "1978-1982    urban_pop_access_drinking  water_total_external_renewable  \n",
       "country                                                                 \n",
       "Afghanistan                        NaN                           18.18  \n",
       "Albania                            NaN                            3.30  \n",
       "Algeria                            NaN                            0.42  \n",
       "Andorra                            NaN                             NaN  \n",
       "Angola                             NaN                            0.40  \n",
       "\n",
       "[5 rows x 60 columns]"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "slice_by_time(data, time_periods[random.randint(0,11)]).head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 正式分析\n",
    "这里抽取了GDP数据进行分析："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Index: 193 entries, Afghanistan to Zimbabwe\n",
      "Data columns (total 12 columns):\n",
      "1958-1962    112 non-null float64\n",
      "1963-1967    119 non-null float64\n",
      "1968-1972    129 non-null float64\n",
      "1973-1977    134 non-null float64\n",
      "1978-1982    147 non-null float64\n",
      "1983-1987    155 non-null float64\n",
      "1988-1992    178 non-null float64\n",
      "1993-1997    183 non-null float64\n",
      "1998-2002    187 non-null float64\n",
      "2003-2007    189 non-null float64\n",
      "2008-2012    191 non-null float64\n",
      "2013-2017    188 non-null float64\n",
      "dtypes: float64(12)\n",
      "memory usage: 18.8+ KB\n"
     ]
    }
   ],
   "source": [
    "data_gdp = slice_by_variable(my_data, 'gdp')\n",
    "data_gdp.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "反正国家这么多，就把有空缺数据的国家drop了"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>time_period</th>\n",
       "      <th>1958-1962</th>\n",
       "      <th>1963-1967</th>\n",
       "      <th>1968-1972</th>\n",
       "      <th>1973-1977</th>\n",
       "      <th>1978-1982</th>\n",
       "      <th>1983-1987</th>\n",
       "      <th>1988-1992</th>\n",
       "      <th>1993-1997</th>\n",
       "      <th>1998-2002</th>\n",
       "      <th>2003-2007</th>\n",
       "      <th>2008-2012</th>\n",
       "      <th>2013-2017</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>country</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>Algeria</td>\n",
       "      <td>2.001461e+09</td>\n",
       "      <td>3.370870e+09</td>\n",
       "      <td>6.761786e+09</td>\n",
       "      <td>2.097190e+10</td>\n",
       "      <td>4.520709e+10</td>\n",
       "      <td>6.674227e+10</td>\n",
       "      <td>4.800330e+10</td>\n",
       "      <td>4.817786e+10</td>\n",
       "      <td>5.676029e+10</td>\n",
       "      <td>1.350000e+11</td>\n",
       "      <td>2.090000e+11</td>\n",
       "      <td>1.670000e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>Argentina</td>\n",
       "      <td>2.445060e+10</td>\n",
       "      <td>2.425667e+10</td>\n",
       "      <td>3.473300e+10</td>\n",
       "      <td>5.678100e+10</td>\n",
       "      <td>8.430749e+10</td>\n",
       "      <td>1.110000e+11</td>\n",
       "      <td>2.290000e+11</td>\n",
       "      <td>2.930000e+11</td>\n",
       "      <td>9.772451e+10</td>\n",
       "      <td>3.290000e+11</td>\n",
       "      <td>6.040000e+11</td>\n",
       "      <td>5.480000e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>Australia</td>\n",
       "      <td>1.988353e+10</td>\n",
       "      <td>3.037854e+10</td>\n",
       "      <td>5.192874e+10</td>\n",
       "      <td>1.100000e+11</td>\n",
       "      <td>1.940000e+11</td>\n",
       "      <td>1.890000e+11</td>\n",
       "      <td>3.250000e+11</td>\n",
       "      <td>4.360000e+11</td>\n",
       "      <td>3.940000e+11</td>\n",
       "      <td>8.530000e+11</td>\n",
       "      <td>1.540000e+12</td>\n",
       "      <td>1.340000e+12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>Austria</td>\n",
       "      <td>7.756110e+09</td>\n",
       "      <td>1.157943e+10</td>\n",
       "      <td>2.200647e+10</td>\n",
       "      <td>5.142159e+10</td>\n",
       "      <td>7.110359e+10</td>\n",
       "      <td>1.240000e+11</td>\n",
       "      <td>1.950000e+11</td>\n",
       "      <td>2.120000e+11</td>\n",
       "      <td>2.130000e+11</td>\n",
       "      <td>3.860000e+11</td>\n",
       "      <td>4.070000e+11</td>\n",
       "      <td>3.740000e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>Bahamas</td>\n",
       "      <td>2.122528e+08</td>\n",
       "      <td>3.901961e+08</td>\n",
       "      <td>5.909000e+08</td>\n",
       "      <td>7.130000e+08</td>\n",
       "      <td>1.578300e+09</td>\n",
       "      <td>2.714000e+09</td>\n",
       "      <td>3.109000e+09</td>\n",
       "      <td>4.961119e+09</td>\n",
       "      <td>6.957996e+09</td>\n",
       "      <td>8.318996e+09</td>\n",
       "      <td>8.234470e+09</td>\n",
       "      <td>8.884441e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>Bangladesh</td>\n",
       "      <td>5.081413e+09</td>\n",
       "      <td>7.253575e+09</td>\n",
       "      <td>6.288246e+09</td>\n",
       "      <td>9.651149e+09</td>\n",
       "      <td>1.852540e+10</td>\n",
       "      <td>2.429803e+10</td>\n",
       "      <td>3.170887e+10</td>\n",
       "      <td>4.824431e+10</td>\n",
       "      <td>5.472408e+10</td>\n",
       "      <td>7.961189e+10</td>\n",
       "      <td>1.330000e+11</td>\n",
       "      <td>1.950000e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>Barbados</td>\n",
       "      <td>9.694976e+07</td>\n",
       "      <td>1.371037e+08</td>\n",
       "      <td>2.333836e+08</td>\n",
       "      <td>4.951166e+08</td>\n",
       "      <td>1.163924e+09</td>\n",
       "      <td>1.704370e+09</td>\n",
       "      <td>1.957000e+09</td>\n",
       "      <td>2.549097e+09</td>\n",
       "      <td>3.169500e+09</td>\n",
       "      <td>4.546000e+09</td>\n",
       "      <td>4.313000e+09</td>\n",
       "      <td>4.451000e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>Belgium</td>\n",
       "      <td>1.326402e+10</td>\n",
       "      <td>1.999204e+10</td>\n",
       "      <td>3.740863e+10</td>\n",
       "      <td>8.328341e+10</td>\n",
       "      <td>9.258898e+10</td>\n",
       "      <td>1.500000e+11</td>\n",
       "      <td>2.360000e+11</td>\n",
       "      <td>2.550000e+11</td>\n",
       "      <td>2.590000e+11</td>\n",
       "      <td>4.720000e+11</td>\n",
       "      <td>4.980000e+11</td>\n",
       "      <td>4.540000e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>Belize</td>\n",
       "      <td>3.185759e+07</td>\n",
       "      <td>4.737931e+07</td>\n",
       "      <td>6.606250e+07</td>\n",
       "      <td>1.176500e+08</td>\n",
       "      <td>1.792500e+08</td>\n",
       "      <td>2.765500e+08</td>\n",
       "      <td>5.182391e+08</td>\n",
       "      <td>6.543144e+08</td>\n",
       "      <td>9.325518e+08</td>\n",
       "      <td>1.290543e+09</td>\n",
       "      <td>1.573619e+09</td>\n",
       "      <td>1.763000e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>Benin</td>\n",
       "      <td>2.364350e+08</td>\n",
       "      <td>3.062220e+08</td>\n",
       "      <td>4.103319e+08</td>\n",
       "      <td>7.500498e+08</td>\n",
       "      <td>1.267779e+09</td>\n",
       "      <td>1.562412e+09</td>\n",
       "      <td>1.695315e+09</td>\n",
       "      <td>2.268302e+09</td>\n",
       "      <td>3.054571e+09</td>\n",
       "      <td>5.969535e+09</td>\n",
       "      <td>8.117101e+09</td>\n",
       "      <td>8.476125e+09</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "time_period     1958-1962     1963-1967     1968-1972     1973-1977  \\\n",
       "country                                                               \n",
       "Algeria      2.001461e+09  3.370870e+09  6.761786e+09  2.097190e+10   \n",
       "Argentina    2.445060e+10  2.425667e+10  3.473300e+10  5.678100e+10   \n",
       "Australia    1.988353e+10  3.037854e+10  5.192874e+10  1.100000e+11   \n",
       "Austria      7.756110e+09  1.157943e+10  2.200647e+10  5.142159e+10   \n",
       "Bahamas      2.122528e+08  3.901961e+08  5.909000e+08  7.130000e+08   \n",
       "Bangladesh   5.081413e+09  7.253575e+09  6.288246e+09  9.651149e+09   \n",
       "Barbados     9.694976e+07  1.371037e+08  2.333836e+08  4.951166e+08   \n",
       "Belgium      1.326402e+10  1.999204e+10  3.740863e+10  8.328341e+10   \n",
       "Belize       3.185759e+07  4.737931e+07  6.606250e+07  1.176500e+08   \n",
       "Benin        2.364350e+08  3.062220e+08  4.103319e+08  7.500498e+08   \n",
       "\n",
       "time_period     1978-1982     1983-1987     1988-1992     1993-1997  \\\n",
       "country                                                               \n",
       "Algeria      4.520709e+10  6.674227e+10  4.800330e+10  4.817786e+10   \n",
       "Argentina    8.430749e+10  1.110000e+11  2.290000e+11  2.930000e+11   \n",
       "Australia    1.940000e+11  1.890000e+11  3.250000e+11  4.360000e+11   \n",
       "Austria      7.110359e+10  1.240000e+11  1.950000e+11  2.120000e+11   \n",
       "Bahamas      1.578300e+09  2.714000e+09  3.109000e+09  4.961119e+09   \n",
       "Bangladesh   1.852540e+10  2.429803e+10  3.170887e+10  4.824431e+10   \n",
       "Barbados     1.163924e+09  1.704370e+09  1.957000e+09  2.549097e+09   \n",
       "Belgium      9.258898e+10  1.500000e+11  2.360000e+11  2.550000e+11   \n",
       "Belize       1.792500e+08  2.765500e+08  5.182391e+08  6.543144e+08   \n",
       "Benin        1.267779e+09  1.562412e+09  1.695315e+09  2.268302e+09   \n",
       "\n",
       "time_period     1998-2002     2003-2007     2008-2012     2013-2017  \n",
       "country                                                              \n",
       "Algeria      5.676029e+10  1.350000e+11  2.090000e+11  1.670000e+11  \n",
       "Argentina    9.772451e+10  3.290000e+11  6.040000e+11  5.480000e+11  \n",
       "Australia    3.940000e+11  8.530000e+11  1.540000e+12  1.340000e+12  \n",
       "Austria      2.130000e+11  3.860000e+11  4.070000e+11  3.740000e+11  \n",
       "Bahamas      6.957996e+09  8.318996e+09  8.234470e+09  8.884441e+09  \n",
       "Bangladesh   5.472408e+10  7.961189e+10  1.330000e+11  1.950000e+11  \n",
       "Barbados     3.169500e+09  4.546000e+09  4.313000e+09  4.451000e+09  \n",
       "Belgium      2.590000e+11  4.720000e+11  4.980000e+11  4.540000e+11  \n",
       "Belize       9.325518e+08  1.290543e+09  1.573619e+09  1.763000e+09  \n",
       "Benin        3.054571e+09  5.969535e+09  8.117101e+09  8.476125e+09  "
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data_gdp = data_gdp.dropna(axis=0)\n",
    "data_gdp.head(10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "现在，输出对各个国家的统计信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>time_period</th>\n",
       "      <th>1958-1962</th>\n",
       "      <th>1963-1967</th>\n",
       "      <th>1968-1972</th>\n",
       "      <th>1973-1977</th>\n",
       "      <th>1978-1982</th>\n",
       "      <th>1983-1987</th>\n",
       "      <th>1988-1992</th>\n",
       "      <th>1993-1997</th>\n",
       "      <th>1998-2002</th>\n",
       "      <th>2003-2007</th>\n",
       "      <th>2008-2012</th>\n",
       "      <th>2013-2017</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>count</td>\n",
       "      <td>1.080000e+02</td>\n",
       "      <td>1.080000e+02</td>\n",
       "      <td>1.080000e+02</td>\n",
       "      <td>1.080000e+02</td>\n",
       "      <td>1.080000e+02</td>\n",
       "      <td>1.080000e+02</td>\n",
       "      <td>1.080000e+02</td>\n",
       "      <td>1.080000e+02</td>\n",
       "      <td>1.080000e+02</td>\n",
       "      <td>1.080000e+02</td>\n",
       "      <td>1.080000e+02</td>\n",
       "      <td>1.080000e+02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>mean</td>\n",
       "      <td>1.220698e+10</td>\n",
       "      <td>1.811036e+10</td>\n",
       "      <td>2.987083e+10</td>\n",
       "      <td>5.703450e+10</td>\n",
       "      <td>9.046258e+10</td>\n",
       "      <td>1.355400e+11</td>\n",
       "      <td>2.018418e+11</td>\n",
       "      <td>2.492498e+11</td>\n",
       "      <td>2.787913e+11</td>\n",
       "      <td>4.529366e+11</td>\n",
       "      <td>5.852008e+11</td>\n",
       "      <td>5.868505e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>std</td>\n",
       "      <td>5.941848e+10</td>\n",
       "      <td>8.516238e+10</td>\n",
       "      <td>1.292524e+11</td>\n",
       "      <td>2.173751e+11</td>\n",
       "      <td>3.465563e+11</td>\n",
       "      <td>5.374212e+11</td>\n",
       "      <td>7.520789e+11</td>\n",
       "      <td>9.476594e+11</td>\n",
       "      <td>1.147249e+12</td>\n",
       "      <td>1.542575e+12</td>\n",
       "      <td>1.875996e+12</td>\n",
       "      <td>2.067757e+12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>min</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>1.347072e+08</td>\n",
       "      <td>2.457815e+08</td>\n",
       "      <td>3.376957e+08</td>\n",
       "      <td>4.214815e+08</td>\n",
       "      <td>4.851852e+08</td>\n",
       "      <td>5.377778e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>25%</td>\n",
       "      <td>2.307012e+08</td>\n",
       "      <td>3.381520e+08</td>\n",
       "      <td>4.566629e+08</td>\n",
       "      <td>9.082938e+08</td>\n",
       "      <td>1.554975e+09</td>\n",
       "      <td>2.214905e+09</td>\n",
       "      <td>2.914281e+09</td>\n",
       "      <td>3.611543e+09</td>\n",
       "      <td>4.019284e+09</td>\n",
       "      <td>7.464191e+09</td>\n",
       "      <td>1.137576e+10</td>\n",
       "      <td>1.066173e+10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>50%</td>\n",
       "      <td>8.627687e+08</td>\n",
       "      <td>1.289027e+09</td>\n",
       "      <td>2.109786e+09</td>\n",
       "      <td>4.429380e+09</td>\n",
       "      <td>8.048770e+09</td>\n",
       "      <td>7.891002e+09</td>\n",
       "      <td>1.133699e+10</td>\n",
       "      <td>1.546468e+10</td>\n",
       "      <td>1.790698e+10</td>\n",
       "      <td>3.323168e+10</td>\n",
       "      <td>5.083778e+10</td>\n",
       "      <td>5.561815e+10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>75%</td>\n",
       "      <td>5.142953e+09</td>\n",
       "      <td>7.291137e+09</td>\n",
       "      <td>1.171799e+10</td>\n",
       "      <td>3.607061e+10</td>\n",
       "      <td>5.327859e+10</td>\n",
       "      <td>6.592513e+10</td>\n",
       "      <td>1.137500e+11</td>\n",
       "      <td>1.195000e+11</td>\n",
       "      <td>1.282500e+11</td>\n",
       "      <td>2.647500e+11</td>\n",
       "      <td>3.727500e+11</td>\n",
       "      <td>3.175000e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>max</td>\n",
       "      <td>6.050000e+11</td>\n",
       "      <td>8.620000e+11</td>\n",
       "      <td>1.280000e+12</td>\n",
       "      <td>2.090000e+12</td>\n",
       "      <td>3.340000e+12</td>\n",
       "      <td>4.870000e+12</td>\n",
       "      <td>6.540000e+12</td>\n",
       "      <td>8.610000e+12</td>\n",
       "      <td>1.100000e+13</td>\n",
       "      <td>1.450000e+13</td>\n",
       "      <td>1.620000e+13</td>\n",
       "      <td>1.790000e+13</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "time_period     1958-1962     1963-1967     1968-1972     1973-1977  \\\n",
       "count        1.080000e+02  1.080000e+02  1.080000e+02  1.080000e+02   \n",
       "mean         1.220698e+10  1.811036e+10  2.987083e+10  5.703450e+10   \n",
       "std          5.941848e+10  8.516238e+10  1.292524e+11  2.173751e+11   \n",
       "min          0.000000e+00  0.000000e+00  0.000000e+00  0.000000e+00   \n",
       "25%          2.307012e+08  3.381520e+08  4.566629e+08  9.082938e+08   \n",
       "50%          8.627687e+08  1.289027e+09  2.109786e+09  4.429380e+09   \n",
       "75%          5.142953e+09  7.291137e+09  1.171799e+10  3.607061e+10   \n",
       "max          6.050000e+11  8.620000e+11  1.280000e+12  2.090000e+12   \n",
       "\n",
       "time_period     1978-1982     1983-1987     1988-1992     1993-1997  \\\n",
       "count        1.080000e+02  1.080000e+02  1.080000e+02  1.080000e+02   \n",
       "mean         9.046258e+10  1.355400e+11  2.018418e+11  2.492498e+11   \n",
       "std          3.465563e+11  5.374212e+11  7.520789e+11  9.476594e+11   \n",
       "min          0.000000e+00  0.000000e+00  1.347072e+08  2.457815e+08   \n",
       "25%          1.554975e+09  2.214905e+09  2.914281e+09  3.611543e+09   \n",
       "50%          8.048770e+09  7.891002e+09  1.133699e+10  1.546468e+10   \n",
       "75%          5.327859e+10  6.592513e+10  1.137500e+11  1.195000e+11   \n",
       "max          3.340000e+12  4.870000e+12  6.540000e+12  8.610000e+12   \n",
       "\n",
       "time_period     1998-2002     2003-2007     2008-2012     2013-2017  \n",
       "count        1.080000e+02  1.080000e+02  1.080000e+02  1.080000e+02  \n",
       "mean         2.787913e+11  4.529366e+11  5.852008e+11  5.868505e+11  \n",
       "std          1.147249e+12  1.542575e+12  1.875996e+12  2.067757e+12  \n",
       "min          3.376957e+08  4.214815e+08  4.851852e+08  5.377778e+08  \n",
       "25%          4.019284e+09  7.464191e+09  1.137576e+10  1.066173e+10  \n",
       "50%          1.790698e+10  3.323168e+10  5.083778e+10  5.561815e+10  \n",
       "75%          1.282500e+11  2.647500e+11  3.727500e+11  3.175000e+11  \n",
       "max          1.100000e+13  1.450000e+13  1.620000e+13  1.790000e+13  "
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data_gdp.describe()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "当然了，在drop了这么多国家之后，这个统计信息基本上没有什么代表性了，不过这只是一个练手项目，所以无所谓。    \n",
    "不过值得一提的是，由于统计数据的缺失大多数由于战乱或者经济发展水平太低导致的，可以推测这时的gdp应该不会太高，我们用0补充，然后再看看统计信息有何变化："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Index: 193 entries, Afghanistan to Zimbabwe\n",
      "Data columns (total 12 columns):\n",
      "1958-1962    193 non-null float64\n",
      "1963-1967    193 non-null float64\n",
      "1968-1972    193 non-null float64\n",
      "1973-1977    193 non-null float64\n",
      "1978-1982    193 non-null float64\n",
      "1983-1987    193 non-null float64\n",
      "1988-1992    193 non-null float64\n",
      "1993-1997    193 non-null float64\n",
      "1998-2002    193 non-null float64\n",
      "2003-2007    193 non-null float64\n",
      "2008-2012    193 non-null float64\n",
      "2013-2017    193 non-null float64\n",
      "dtypes: float64(12)\n",
      "memory usage: 18.8+ KB\n"
     ]
    }
   ],
   "source": [
    "data_gdp_fill = slice_by_variable(my_data, 'gdp')\n",
    "data_gdp_fill = data_gdp_fill.fillna(0)\n",
    "data_gdp_fill.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>time_period</th>\n",
       "      <th>1958-1962</th>\n",
       "      <th>1963-1967</th>\n",
       "      <th>1968-1972</th>\n",
       "      <th>1973-1977</th>\n",
       "      <th>1978-1982</th>\n",
       "      <th>1983-1987</th>\n",
       "      <th>1988-1992</th>\n",
       "      <th>1993-1997</th>\n",
       "      <th>1998-2002</th>\n",
       "      <th>2003-2007</th>\n",
       "      <th>2008-2012</th>\n",
       "      <th>2013-2017</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>count</td>\n",
       "      <td>1.930000e+02</td>\n",
       "      <td>1.930000e+02</td>\n",
       "      <td>1.930000e+02</td>\n",
       "      <td>1.930000e+02</td>\n",
       "      <td>1.930000e+02</td>\n",
       "      <td>1.930000e+02</td>\n",
       "      <td>1.930000e+02</td>\n",
       "      <td>1.930000e+02</td>\n",
       "      <td>1.930000e+02</td>\n",
       "      <td>1.930000e+02</td>\n",
       "      <td>1.930000e+02</td>\n",
       "      <td>1.930000e+02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>mean</td>\n",
       "      <td>6.843910e+09</td>\n",
       "      <td>1.019667e+10</td>\n",
       "      <td>1.845111e+10</td>\n",
       "      <td>3.566941e+10</td>\n",
       "      <td>5.605596e+10</td>\n",
       "      <td>8.459257e+10</td>\n",
       "      <td>1.298776e+11</td>\n",
       "      <td>1.584194e+11</td>\n",
       "      <td>1.749234e+11</td>\n",
       "      <td>2.936402e+11</td>\n",
       "      <td>3.803892e+11</td>\n",
       "      <td>3.749161e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>std</td>\n",
       "      <td>4.476936e+10</td>\n",
       "      <td>6.420305e+10</td>\n",
       "      <td>9.968403e+10</td>\n",
       "      <td>1.696010e+11</td>\n",
       "      <td>2.675145e+11</td>\n",
       "      <td>4.157537e+11</td>\n",
       "      <td>5.881348e+11</td>\n",
       "      <td>7.329445e+11</td>\n",
       "      <td>8.776142e+11</td>\n",
       "      <td>1.195156e+12</td>\n",
       "      <td>1.451301e+12</td>\n",
       "      <td>1.584401e+12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>min</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000e+00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>25%</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>0.000000e+00</td>\n",
       "      <td>3.491800e+07</td>\n",
       "      <td>1.407056e+08</td>\n",
       "      <td>1.083038e+09</td>\n",
       "      <td>1.498951e+09</td>\n",
       "      <td>1.661818e+09</td>\n",
       "      <td>4.010785e+09</td>\n",
       "      <td>6.074884e+09</td>\n",
       "      <td>6.565382e+09</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>50%</td>\n",
       "      <td>1.244828e+08</td>\n",
       "      <td>2.270000e+08</td>\n",
       "      <td>4.060842e+08</td>\n",
       "      <td>7.774351e+08</td>\n",
       "      <td>2.017612e+09</td>\n",
       "      <td>2.353864e+09</td>\n",
       "      <td>4.848057e+09</td>\n",
       "      <td>6.522759e+09</td>\n",
       "      <td>7.850809e+09</td>\n",
       "      <td>1.970762e+10</td>\n",
       "      <td>2.647206e+10</td>\n",
       "      <td>2.780575e+10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>75%</td>\n",
       "      <td>1.382516e+09</td>\n",
       "      <td>2.366839e+09</td>\n",
       "      <td>5.043268e+09</td>\n",
       "      <td>1.313940e+10</td>\n",
       "      <td>2.121651e+10</td>\n",
       "      <td>2.521361e+10</td>\n",
       "      <td>3.854149e+10</td>\n",
       "      <td>4.824431e+10</td>\n",
       "      <td>5.676029e+10</td>\n",
       "      <td>1.370000e+11</td>\n",
       "      <td>2.060000e+11</td>\n",
       "      <td>1.840000e+11</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <td>max</td>\n",
       "      <td>6.050000e+11</td>\n",
       "      <td>8.620000e+11</td>\n",
       "      <td>1.280000e+12</td>\n",
       "      <td>2.090000e+12</td>\n",
       "      <td>3.340000e+12</td>\n",
       "      <td>4.870000e+12</td>\n",
       "      <td>6.540000e+12</td>\n",
       "      <td>8.610000e+12</td>\n",
       "      <td>1.100000e+13</td>\n",
       "      <td>1.450000e+13</td>\n",
       "      <td>1.620000e+13</td>\n",
       "      <td>1.790000e+13</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "time_period     1958-1962     1963-1967     1968-1972     1973-1977  \\\n",
       "count        1.930000e+02  1.930000e+02  1.930000e+02  1.930000e+02   \n",
       "mean         6.843910e+09  1.019667e+10  1.845111e+10  3.566941e+10   \n",
       "std          4.476936e+10  6.420305e+10  9.968403e+10  1.696010e+11   \n",
       "min          0.000000e+00  0.000000e+00  0.000000e+00  0.000000e+00   \n",
       "25%          0.000000e+00  0.000000e+00  0.000000e+00  0.000000e+00   \n",
       "50%          1.244828e+08  2.270000e+08  4.060842e+08  7.774351e+08   \n",
       "75%          1.382516e+09  2.366839e+09  5.043268e+09  1.313940e+10   \n",
       "max          6.050000e+11  8.620000e+11  1.280000e+12  2.090000e+12   \n",
       "\n",
       "time_period     1978-1982     1983-1987     1988-1992     1993-1997  \\\n",
       "count        1.930000e+02  1.930000e+02  1.930000e+02  1.930000e+02   \n",
       "mean         5.605596e+10  8.459257e+10  1.298776e+11  1.584194e+11   \n",
       "std          2.675145e+11  4.157537e+11  5.881348e+11  7.329445e+11   \n",
       "min          0.000000e+00  0.000000e+00  0.000000e+00  0.000000e+00   \n",
       "25%          3.491800e+07  1.407056e+08  1.083038e+09  1.498951e+09   \n",
       "50%          2.017612e+09  2.353864e+09  4.848057e+09  6.522759e+09   \n",
       "75%          2.121651e+10  2.521361e+10  3.854149e+10  4.824431e+10   \n",
       "max          3.340000e+12  4.870000e+12  6.540000e+12  8.610000e+12   \n",
       "\n",
       "time_period     1998-2002     2003-2007     2008-2012     2013-2017  \n",
       "count        1.930000e+02  1.930000e+02  1.930000e+02  1.930000e+02  \n",
       "mean         1.749234e+11  2.936402e+11  3.803892e+11  3.749161e+11  \n",
       "std          8.776142e+11  1.195156e+12  1.451301e+12  1.584401e+12  \n",
       "min          0.000000e+00  0.000000e+00  0.000000e+00  0.000000e+00  \n",
       "25%          1.661818e+09  4.010785e+09  6.074884e+09  6.565382e+09  \n",
       "50%          7.850809e+09  1.970762e+10  2.647206e+10  2.780575e+10  \n",
       "75%          5.676029e+10  1.370000e+11  2.060000e+11  1.840000e+11  \n",
       "max          1.100000e+13  1.450000e+13  1.620000e+13  1.790000e+13  "
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data_gdp_fill.describe()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "这样中位数应该与实际情况更加相近，平均值应该也有所改善，但是标准差就不一定了。    \n",
    "为了后面分析的方便，我们还是使用drop部分国家的版本而非补0版本。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 位置性测度与离散性测度\n",
    "其实上面的表格已经有了相关的数据，这里更多是为了练习分别抽取测度数据的命令。     \n",
    "随机抽取一年，进行输出如下："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "country\n",
      "Algeria                               1.670000e+11\n",
      "Argentina                             5.480000e+11\n",
      "Australia                             1.340000e+12\n",
      "Austria                               3.740000e+11\n",
      "Bahamas                               8.884441e+09\n",
      "                                          ...     \n",
      "United States of America              1.790000e+13\n",
      "Uruguay                               5.344270e+10\n",
      "Venezuela (Bolivarian Republic of)    3.710000e+11\n",
      "Zambia                                2.120156e+10\n",
      "Zimbabwe                              1.389294e+10\n",
      "Name: 2013-2017, Length: 108, dtype: float64\n",
      "2013-2017\n",
      "位置性测度统计结果：\n",
      "均值：\t\t 586850542773.037\n",
      "中位数：\t 55618154817.0\n",
      "第25个百分位数： 10661729265.0\n"
     ]
    }
   ],
   "source": [
    "temp_year = random.randint(1,11)\n",
    "print(data_gdp[time_periods[temp_year]])\n",
    "print(time_periods[temp_year])\n",
    "print('位置性测度统计结果：')\n",
    "print('均值：\\t\\t',data_gdp[time_periods[temp_year]].mean())\n",
    "print('中位数：\\t',data_gdp[time_periods[temp_year]].median())\n",
    "print('第25个百分位数：',data_gdp[time_periods[temp_year]].quantile(q=0.25))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "离散性测度统计结果：\n",
      "变化范围：\t [ 537777778.0 \t 17900000000000.0 ]\n",
      "极差：\t\t 17899462222222.0\n",
      "方差：\t\t 4.275620943608562e+24\n",
      "标准差：\t 2067757467308.1372\n",
      "变异系数：\t 3.523482243941346\n"
     ]
    }
   ],
   "source": [
    "print('离散性测度统计结果：')\n",
    "print('变化范围：\\t [',data_gdp[time_periods[temp_year]].min(),'\\t',data_gdp[time_periods[temp_year]].max(),']')\n",
    "print('极差：\\t\\t',data_gdp[time_periods[temp_year]].max()-data_gdp[time_periods[temp_year]].min())\n",
    "print('方差：\\t\\t',data_gdp[time_periods[temp_year]].var())\n",
    "print('标准差：\\t',data_gdp[time_periods[temp_year]].std())\n",
    "print('变异系数：\\t',data_gdp[time_periods[temp_year]].std()/data_gdp[time_periods[temp_year]].mean())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 可视化\n",
    "使用直方图和箱型图，对上述一个年份的数据进行可视化操作："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x6b8a45b0>"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAEJCAYAAACE39xMAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAE4BJREFUeJzt3X2QXXV9x/H3VyKoWSWJyBoDTaBmUBQRN2UQKnVBK2Lb0Kl0cKwTbZyMVRlnrC2xznTaTjvitFMrUzuVgjUdLAumNdCAWhoWbatEE+VRjEHIIAMmah50lcGi3/5xT/SyJjln7+69d8/P92vmzp6H37n7ycmdz54995y7kZlIktrvKcMOIEmaGxa6JBXCQpekQljoklQIC12SCmGhS1IhLHRJKoSFLkmFsNAlqRALBvnNjjvuuFyxYkVP2/7gBz9g4cKFcxuoT9qStS05oT1Z25IT2pO1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Bf3a06QAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "data_gdp[time_periods[temp_year]].hist(bins=200)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "不得不说，贫富差距看上去真的很触目惊心。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x6bd65750>"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYcAAAEDCAYAAADeP8iwAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzt3Xt8lOWZ//HPlQSDEk4RiVjU0K1tA3hgYbVVfpaUFaz7W+3+1JXUuh5ieZUt6Ha3W6XZ1to2rbjb7bboVmwDXbtLaLerrlUpdSHUpdauuhwaTLWoWCkqVlROghCu3x/PPWGSmSSTMM/MZPJ9v17Pa2aew1zPPYfneu77fg7m7oiIiCQryfcKiIhI4VFyEBGRFEoOIiKSQslBRERSKDmIiEgKJQcREUlRsMnBzJaa2Q4za81g3vPN7H/N7JCZXZY0/lQze8rMNpjZZjP7ZLxrLSJSHKxQz3Mws/OBPcA97j65l3mrgRHAZ4AH3P1HYfwxRGU8YGYVQCtwrrtvj3PdRUQGuoKtObj7o8DO5HFm9gdm9pNQG/hvM3t/mHeru28CDnd5j3fc/UB4WU4Bl1dEpJAMtI3l3cACd59KVEv4594WMLOTzWwT8BKwSLUGEZHeleV7BTIVmoXOBf7dzBKjy3tbzt1fAs4ws5OA+83sR+7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dPo93iPbWVxL1CVSFzzJRvsT3l658ffk8q0MZDoR464guA53R90fUL+EcOeT1baJkdzxRIkgcyvozop0iI2o2eyu87xaiWt8FRBvsxHu9FMp3Vpd4d6eJVxfi/Q9HDi39DkcOZf0uRw5l/Z+wHqUc6ax+C/jHbr67vsY7kSgBHw7LtRN1wJ8RYh0O75H4fY7tEu/jRL+n5ENQzwrT3h1ibiFKoOVh/B8RbV/2Ev2WNie9XzVRYi7JZNuty2eIiEgKnSEtIiIplBxERCSFkoOIiKRQchARkRRKDiIikkLJQUREUig5iIhIiv8PeauLrVDOc9cAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "data_gdp.boxplot()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "由于箱型图的输入必须是一个DataFrame，所以索性使用整个gdp表进行可视化，还可以顺便观察到随年份变化的趋势。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "通过可视化数据，可以清晰地看出，世界上的贫富差距不仅很大，而且越来越大。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 总结\n",
    "通过此次作业，练习了不少读取、处理、可视化数据的技能，同时对EDA的流程有了初步的认识。     \n",
    "从总结的统计数据可以看出，世界上的大国“很大”，导致GDP的均值不仅比中位数大，而且差距非常之大，同时，部分国家的发展速度令人震惊（比如说虽然箱型图不标数据label，但是最上面那个谁都能猜出来是美国）。     \n",
    "美中不足的是，这次使用的是GDP总量进行分析，如果在slice的时候选择gdp_per_capita字段，就可以分析均值，或者也可以手动以population等字段相除，得出结果。     \n",
    "（不过这样恐怕美国的数据会更加夸张吧）"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
